<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring Boot Actuator 深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            overflow-x: auto;
        }
        
        .code-block pre {
            margin: 0;
            padding: 1.5rem;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            margin: 1.5rem 0;
            position: relative;
            overflow: hidden;
        }
        
        .highlight-box::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: shimmer 3s infinite;
        }
        
        @keyframes shimmer {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                    Spring Boot Actuator
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    生产环境监控的强大利器
                </p>
                <div class="flex justify-center space-x-6 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-heartbeat mr-2"></i>
                        <span>健康检查</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-chart-line mr-2"></i>
                        <span>性能监控</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-cogs mr-2"></i>
                        <span>运维管理</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="bg-white rounded-xl shadow-xl p-8 mb-12 card-hover">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">S</span>pring Boot Actuator 是 Spring Boot 提供的一组生产环境监控功能，它为 Spring Boot 应用提供了许多关键指标、健康检查、应用状态等信息，帮助开发者更好地运维和监控应用。Spring Boot Actuator 提供了许多内置的端点，如健康检查、应用信息、度量指标等，这些端点可以用于查看应用的运行状态以及性能数据。
            </p>
        </div>

        <!-- Section 1: Overview -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 section-title">1. Spring Boot Actuator 概述</h2>
            
            <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                <p class="text-lg mb-6 text-gray-700 leading-relaxed">
                    Spring Boot Actuator 提供了一系列预定义的端点，可以通过 HTTP、JMX 或其他协议访问这些端点。常见的端点包括：
                </p>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div class="bg-gradient-to-r from-purple-50 to-pink-50 p-4 rounded-lg card-hover">
                        <div class="flex items-center">
                            <i class="fas fa-heart text-2xl text-pink-500 mr-3"></i>
                            <div>
                                <code class="text-purple-700 font-mono">/actuator/health</code>
                                <p class="text-gray-600 text-sm mt-1">健康检查</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-r from-blue-50 to-cyan-50 p-4 rounded-lg card-hover">
                        <div class="flex items-center">
                            <i class="fas fa-chart-bar text-2xl text-blue-500 mr-3"></i>
                            <div>
                                <code class="text-blue-700 font-mono">/actuator/metrics</code>
                                <p class="text-gray-600 text-sm mt-1">度量指标</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-r from-green-50 to-emerald-50 p-4 rounded-lg card-hover">
                        <div class="flex items-center">
                            <i class="fas fa-info-circle text-2xl text-green-500 mr-3"></i>
                            <div>
                                <code class="text-green-700 font-mono">/actuator/info</code>
                                <p class="text-gray-600 text-sm mt-1">应用信息</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-r from-yellow-50 to-orange-50 p-4 rounded-lg card-hover">
                        <div class="flex items-center">
                            <i class="fas fa-globe text-2xl text-orange-500 mr-3"></i>
                            <div>
                                <code class="text-orange-700 font-mono">/actuator/env</code>
                                <p class="text-gray-600 text-sm mt-1">应用环境变量</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <p class="text-lg mt-6 text-gray-700 leading-relaxed">
                    Spring Boot Actuator 的核心实现是通过对 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">@Endpoint</code> 注解的类的扫描和注册实现的，同时它还依赖于 Spring Boot 的自动配置机制来加载和配置各个端点。
                </p>
            </div>
        </section>

        <!-- Architecture Diagram -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h3 class="text-2xl font-bold mb-6 text-center">Actuator 架构概览</h3>
                <div class="mermaid">
                    graph TB
                        A[Spring Boot Application] --> B[Actuator Auto Configuration]
                        B --> C[Endpoint Discovery]
                        C --> D[Health Endpoint]
                        C --> E[Metrics Endpoint]
                        C --> F[Info Endpoint]
                        C --> G[Custom Endpoints]
                        D --> H[Health Indicators]
                        E --> I[Meter Registry]
                        H --> J[Database Health]
                        H --> K[Disk Space Health]
                        H --> L[Custom Health]
                        style A fill:#667eea,stroke:#fff,color:#fff
                        style B fill:#764ba2,stroke:#fff,color:#fff
                        style D fill:#f093fb,stroke:#fff,color:#fff
                        style E fill:#f5576c,stroke:#fff,color:#fff
                </div>
            </div>
        </section>

        <!-- Section 2: Implementation -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 section-title">2. Actuator 端点的实现</h2>
            
            <!-- 2.1 Basic Structure -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">2.1 端点的基本结构</h3>
                <div class="bg-white rounded-xl shadow-lg p-8">
                    <p class="text-lg mb-6 text-gray-700 leading-relaxed">
                        Spring Boot Actuator 的每个端点实现都继承自 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">AbstractEndpoint</code>，这个类为所有端点提供了基础功能，例如：初始化、响应请求等。
                    </p>
                    
                    <div class="code-block">
                        <pre><code class="language-java">public abstract class AbstractEndpoint&lt;T&gt; {
    private final String id;

    protected AbstractEndpoint(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public abstract T invoke();
}</code></pre>
                    </div>
                    
                    <p class="text-lg mt-6 text-gray-700 leading-relaxed">
                        <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">AbstractEndpoint</code> 类定义了端点的基本信息，包括端点的 ID 和方法 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">invoke()</code>，后者用于处理请求并返回响应。
                    </p>
                </div>
            </div>

            <!-- 2.2 Health Endpoint -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">2.2 健康检查端点（/actuator/health）</h3>
                <div class="bg-white rounded-xl shadow-lg p-8">
                    <div class="highlight-box mb-6">
                        <i class="fas fa-heartbeat mr-2"></i>
                        健康检查是 Actuator 中一个非常重要的端点，它用来检查应用的健康状况。例如：数据库连接是否正常，缓存是否可用等。
                    </div>
                    
                    <p class="text-lg mb-6 text-gray-700 leading-relaxed">
                        <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">HealthEndpoint</code> 是用于实现健康检查的核心类。它通过实现 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">Endpoint&lt;Health&gt;</code> 接口并继承 <code class="bg-gray-100 px-2 py-1 rounded text-purple-600">AbstractEndpoint</code> 来实现健康检查端点。
                    </p>
                    
                    <div class="code-block">
                        <pre><code class="language-java">@Component
@Endpoint(id = "health")
public class HealthEndpoint extends AbstractEndpoint&lt;Health&gt; {

    private final HealthIndicatorRegistry healthIndicatorRegistry;

    public HealthEndpoint(HealthIndicatorRegistry healthIndicatorRegistry) {
        super("health");
        this.healthIndicatorRegistry = healthIndicatorRegistry;
    }

    @Override
    public Health invoke() {
        return this.healthIndicatorRegistry.getHealth();
    }
}</code></pre>
                    </div>
                    
                    <div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="bg-green-50 p-4 rounded-lg text-center">
                            <i class="fas fa-check-circle text-3xl text-green-500 mb-2"></i>
                            <p class="font-semibold text-green-700">UP</p>
                            <p class="text-sm text-gray-600">服务正常</p>
                        </div>
                        <div class="bg-red-50 p-4 rounded-lg text-center">
                            <i class="fas fa-times-circle text-